﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;

namespace VietnameseSlangBackend.WebServices
{
    /// <summary>
    /// Summary description for Dictionary1
    /// </summary>
    public class Dictionary1 : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            Word[] words = new Word[2];

            Tag[] tags = new Tag[1];
            tags[0] = new Tag()
            {
                Name = "insult"
            };

            Word firstWord = new Word()
            {
                Name = "đụ má",
                ShortDescription = "fuck your mother",
                LongDescription = "an insult in a form that the person will fuck the other person's mom",
                Example = "đụ má mày",
                ThumbsUp = 5,
                ThumbsDown = 9,
                Tags = tags
            };
            words[0] = firstWord;

            Word secondWord = new Word()
            {
                Name = "dcm",
                ShortDescription = "damn",
                LongDescription = "an expression to show anger",
                Example = "dcm, đúng chó",
                ThumbsUp = 5,
                ThumbsDown = 9,
                Tags = tags
            };
            words[1] = secondWord;

            
            // Return JSON data
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strJSON = js.Serialize(words);

            context.Response.Write(strJSON);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}